import { createRouter, createWebHistory } from 'vue-router'
// import { useLoadingStore } from '../ts/pinia'; //加载动画
// 主页页面相关
import Home from '../views/main/Home.vue';
import MainMessage from '../views/main/MainMessage.vue';
import Api from '../views/api/Api.vue';
import MainFrame from '../views/main/MainFrame.vue';
import DynamicHome from '../views/dynamic/DynamicHome.vue';
import LogHome from '../views/log/LogHome.vue';
import Login from '../views/main/Login.vue';
// 文章相关页面
import ArticlesFrame from '../views/articles/ArticlesFrame.vue';
import ArticlesHome from '../views/articles/ArticlesHome.vue';
import ArticlesTimeLine from '../views/articles/ArticlesTimeLine.vue';
import ArticlesCategory from '../views/articles/ArticlesCategory.vue';
import ArticlePage from '../views/articles/ArticlePage.vue';

// 其他页面
import AboutMe from '../views/AboutMe.vue';
import NotFound from '../views/status/NotFound.vue';

// 超级管理页员页面的相关组件
import ManageFrame from '../views/manage/adminmanager/ManageFrame.vue';
import ManagePanle from '../views/manage/adminmanager/ManagePanle.vue';
import ManageVisitors from '../views/manage/adminmanager/ManageVisitors.vue';
import ManageArticles from '../views/manage/adminmanager/ManageArticles.vue';
import ManageAccounts from '../views/manage/adminmanager/ManageAccounts.vue';
import ManageSeetings from '../views/manage/adminmanager/ManageSeetings.vue';

// 用户管理相关页面
import UserManageFrame from '../views/manage/usermanage/UserManageFrame.vue';
import UserManageArticles from '../views/manage/usermanage/UserManageArticles.vue';
import UserManageEditArticle from '../views/manage/usermanage/UserManageEditArticle.vue';
import UserManageSeeting from '../views/manage/usermanage/UserManageSeeting.vue';
import UserManageDynamic from '../views/manage/usermanage/UserManageDynamic.vue';

import test from '../views/test.vue';
const router = createRouter({
  history: createWebHistory(),

  routes: [
    {
      path: '/', redirect: '/main',
    },
    // 主页页面相关
    {
      path: '/main', redirect: '/main/home',// 这里的组件有右下角菜单栏
      component: MainFrame,
      children: [
        {
          path: '/main/home',
          component: Home,
        }, {
          path: '/main/message',
          component: MainMessage,
        }, {
          path: '/main/api',
          component: Api,
        },
      ]
    },
    // 文章页面相关
    {
      path: '/articles', redirect: '/articles/home',
      component: ArticlesFrame,
      children: [
        {
          path: '/articles/home',
          component: ArticlesHome,
        }, {
          path: '/articles/category',
          component: ArticlesCategory,
        }, {
          path: '/articles/timeline',
          component: ArticlesTimeLine,
        }, {
          path: '/articles/content/:id', //id动态传
          component: ArticlePage
        }
      ]
    },
    // 管理员管理端
    {
      path: '/manage',
      component: ManageFrame, redirect: '/manage/managePanel',
      children: [
        {
          path: '/manage/managePanel',
          component: ManagePanle,
        }, {
          path: '/manage/manageVisitors',
          component: ManageVisitors,
        }, {
          path: '/manage/manageArticles',
          component: ManageArticles,
        }, {
          path: '/manage/manageAccounts',
          component: ManageAccounts,
        }, {
          path: '/manage/manageSeetings',
          component: ManageSeetings,
        }
      ]
    },
    // 用户管理端
    {
      path: '/user',
      component: UserManageFrame, redirect: '/user/articles',
      children: [
        {
          path: '/user/manageArticles',
          component: UserManageArticles
        }, {
          path: '/user/editarticle/:id',
          component: UserManageEditArticle
        }, {
          path: '/user/seeting',
          component: UserManageSeeting
        },{
          path: '/user/manageDynamic',
          component: UserManageDynamic
        }
      ]
    },
    {
      path: '/login',
      component: Login,
    }, {
      path: '/status',
      children: [
        {
          path: '/:pathMatch(.*)*',
          component: NotFound,
        },
      ]
    },
    {
      path: '/AboutMe',
      component: AboutMe
    }, {
      path: '/dynamic',
      component: DynamicHome
    }, {
      path: '/log',
      component: LogHome
    },{
      path: '/test',
      component: test
    }
  ],
})

// 路由跳转之前
router.beforeEach((to, from, next) => {
  // useLoadingStore().show()
  // setTimeout(() => {
  next();
  // }, 550);


});
//路由跳转之后
router.afterEach(() => {


});
export default router;